package com.nanhai.buddhist.college.module.study.controller.teacher;

import com.nanhai.buddhist.college.framework.common.pojo.CommonResult;
import com.nanhai.buddhist.college.module.study.controller.admin.timetable.vo.ClassTimetableRespVO;
import com.nanhai.buddhist.college.module.study.convert.timetable.ClassTimetableConvert;
import com.nanhai.buddhist.college.module.study.dal.dataobject.timetable.ClassTimetableDO;
import com.nanhai.buddhist.college.module.study.service.timetable.ClassTimetableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.nanhai.buddhist.college.framework.common.pojo.CommonResult.success;

/**
 * @author AKai
 * @date 2022/9/28
 */
@Api(tags = "教师PC端 - 教师课程表")
@RestController
@RequestMapping("/study/teacher/timetable")
@Validated
public class TeacherTimetableController {
    @Resource
    private ClassTimetableService classTimetableService;

    @GetMapping("/getClassTimetableListByTeacherId")
    @ApiOperation("根据教师ID获取教师课程表")
    public CommonResult<List<ClassTimetableRespVO>> getClassTimetableListByTeacherId(@RequestParam("teacherId") String classId) {
        List<ClassTimetableDO> list = classTimetableService.getClassTimetableListByTeacherId(classId);
        return success(classTimetableService.coverNames(list));
    }

    @GetMapping("/get")
    @ApiOperation("获得课程")
    public CommonResult<ClassTimetableRespVO> getClassTimetable(@RequestParam("id") Long id) {
        ClassTimetableDO classTimetable = classTimetableService.getClassTimetable(id);
        return success(ClassTimetableConvert.INSTANCE.convert(classTimetable));
    }

    @GetMapping("/getQrCodeStr")
    @ApiOperation("获取生成二维码字符串")
    public CommonResult<String> getQrCodeStr(Long id) {
        return success(classTimetableService.getQrCodeStr(id));
    }


}
